package com.qianya.oa.mapper;

import com.qianya.oa.domain.UserSign;
import com.qianya.oa.vo.UserSignVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserSignMapper {
    List<UserSignVo> getAllUserSigns();
    List<UserSign> getUserSignsByUserId(Integer uid);
    int addUserSign(UserSign userSign);
    UserSignVo getUserSignById(Integer id);
    int updateUserSign(UserSign userSign);
    int deleteUserSign(Integer id);

    List<UserSignVo> getAllUserSignsByTime(String begin ,String end);
    @Select("SELECT \n" +
            "    u.user_id,\n" +
            "    u.user_name,\n" +
            "    us.position,\n" +
            "    us.lon,\n" +
            "    us.lat,\n" +
            "    us.remark,\n" +
            "    us.create_time,\n" +
            "    us.img,\n" +
            "    us.customer_id ,\n" +
            "    sh.hospital_name,\n" +
            "    us.sign_date,\n" +
            "    us.sign_time,\n" +
            "    us.address\n" +
            "FROM sys_user u\n" +
            "LEFT JOIN (\n" +
            "    SELECT \n" +
            "        us.uid,\n" +
            "        us.position,\n" +
            "        us.lon,\n" +
            "        us.lat,\n" +
            "        us.remark,\n" +
            "        us.create_time,\n" +
            "        us.img,\n" +
            "        us.customer_id,\n" +
            "        us.sign_date,\n" +
            "        us.sign_time,\n" +
            "        us.address\n" +
            "    FROM user_sign us\n" +
            "    WHERE us.create_time >= CURDATE() AND us.create_time < CURDATE() + INTERVAL 1 DAY\n" +
            ") us ON u.user_id = us.uid\n" +
            "LEFT JOIN sys_hospital sh ON us.customer_id = sh.id\n" +
            "WHERE u.dept_id = 100\n" +
            "ORDER BY us.create_time DESC;\n")

    List<UserSignVo> teamSignsInfoToday(@Param("deptId") Integer deptId);


}
